package com.everest;
import java.awt.*;
public class Blood {
	int x,y;
	public static final int WIDTH = 15;
	public static final int HEIGHT = 15;
	private TankClient tc;
	int step = 0;
	private boolean live = false;
	public static int r = Tank.r.nextInt(20)+1;
	
	private int times = 0;
	
	int[][] pos = {
			{300,240},{310,220},{330,200},{360,240},{350,300},{360,200},
			//{400,300},{360,280},{330,200},{350,260},{360,250},{330,260}		
	              };
	int[][] pos2 = {
			//{300,240},{310,220},{330,200},{360,240},{350,300},{360,200},
			{100,300},{110,280},{120,260},{150,280},{180,250},{220,260}		
	               };
	
	public Blood(TankClient tc) {
		
		if(r < 10){
			x = pos[0][0];
			y = pos[0][1];
		}
		else {
			x = pos2[0][0];
			y = pos2[0][1];
		}
		this.tc = tc;
	}
	

	public void draw(Graphics g) {
		if(!live) return;
		Color c = g.getColor();
		g.setColor(Color.RED);
		g.fillRect(x, y, WIDTH, HEIGHT);
		g.setColor(c);
		move();
	}
	
	public void move() {
		step++;
		if(step>=pos.length) {
			step = 0;
			times++;
			if(times > 20)  {
				tc.b.setLive(false);
				times = 0;
			}
		}
		if(r < 10){
			x = pos[step][0];
			y = pos[step][1];
		}
		else {
			x = pos2[step][0];
			y = pos2[step][1];
		}
	}


	public boolean isLive() {
		return live;
	}


	public void setLive(boolean live) {
		this.live = live;
	}


	public Rectangle getRect() {
		return new Rectangle(x,y,WIDTH,HEIGHT);
	}
}
